[feat] 問題集の詳細ページで管理者と投票結果の差分を表すアイコンを表示する#3588
Conversation
Fetch vote grade statistics alongside task results in parallel and display RelativeEvaluationBadge on each task's grade icon when the task has a confirmed grade and a known vote median. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughサーバー側でタスク結果と投票グレード統計を並列取得して返し、クライアント側で受け取った voteStatisticsMap を使って各タスク行に相対評価バッジを条件付きレンダリングします。 Changes投票統計に基づく相対評価バッジ表示
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/routes/workbooks/`[slug]/+page.server.ts:
- Around line 40-43: getVoteGradeStatistics currently loads global vote
statistics via findMany for every request; change it to accept a list of taskIds
(e.g., taskIds: string[]) and return statistics filtered to only those taskIds
so we don't scan all rows. Update the call in +page.server.ts (where
getVoteGradeStatistics() is invoked alongside
taskResultsCrud.getTaskResultsByTaskId) to pass workBook.workBookTasks.map(t =>
t.taskId) (or similar) and rename or add a helper (e.g.,
getVoteGradeStatisticsForTaskIds) if you prefer non-breaking changes; ensure the
DB query uses a WHERE IN (taskId) filter and returns the same shape used by the
page.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 77c8842e-9bcb-45b2-8a29-a400e4f23888
📒 Files selected for processing (2)
src/routes/workbooks/[slug]/+page.server.tssrc/routes/workbooks/[slug]/+page.svelte
Replace the full-table getVoteGradeStatistics() with a new getVoteGradeStatisticsForTaskIds() that issues a WHERE IN query, avoiding a full scan of votedGradeStatistics on each workbook page load. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
問題集詳細ページ(/workbooks/[slug])のグレード表示に、管理者確定グレードと投票中央値の差分を示す RelativeEvaluationBadge を重ねて表示できるようにするPRです。サーバ側では投票統計をタスク結果と並列に取得してページへ渡します。
Changes:
- 問題集詳細ページのサーバ load で、タスク結果と投票統計を
Promise.allで並列取得しvoteStatisticsMapを返却 - 問題集詳細ページのグレード列で、確定グレードかつ投票統計がある場合に差分バッジを表示
- 投票統計サービスに taskId 配列で絞り込む取得関数を追加し、ユニットテストを追加
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/routes/workbooks/[slug]/+page.server.ts | タスク結果と投票統計を並列取得し、voteStatisticsMap をページデータに追加 |
| src/routes/workbooks/[slug]/+page.svelte | RelativeEvaluationBadge をグレードアイコンに重ねて表示(条件付き) |
| src/features/votes/services/vote_statistics.ts | getVoteGradeStatisticsForTaskIds を追加して絞り込み取得を実装 |
| src/features/votes/services/vote_statistics.test.ts | getVoteGradeStatisticsForTaskIds のユニットテストを追加 |
…sticsForTaskIds Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@KATO-Hiro |
Summary
RelativeEvaluationBadgeを追加し、管理者確定グレードと投票中央値の差分アイコンを表示するgetVoteGradeStatistics) をタスク結果と並列取得してページに渡すChanges
src/routes/workbooks/[slug]/+page.server.ts:getVoteGradeStatistics()をtaskResultsCrud.getTaskResultsByTaskId()とPromise.allで並列取得し、voteStatisticsMapを返すsrc/routes/workbooks/[slug]/+page.svelte:RelativeEvaluationBadgeをインポートし、グレードアイコンの右上に差分バッジを表示(確定グレードかつ投票中央値がある場合のみ)Test plan
++/+/±0/-/--)が表示されることを確認PENDINGグレードのタスクにはバッジが表示されないことを確認pnpm format && pnpm check && pnpm test:unitがすべてパスすることを確認🤖 Generated with Claude Code
Summary by CodeRabbit